<!DOCTYPE html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <title>个人中心</title>
      <link rel="stylesheet" type="text/css" href="../../css/api.css" />
      <link rel="stylesheet" type="text/css" href="../../css/common.css" />
      <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    	<link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
      <style>
          html, body {width: 100%;min-height: 100%;background: #F3EFEE;}
          .aui-active .aui-bar-tab-label{
            color: #f5a51c
          }
          .login {height:240px;background-image: -webkit-linear-gradient(0deg, #f5c674, #ed824c);/*background-image: url(../../image/personal_bkg.jpg);background-repeat: no-repeat; background-size: cover;*/position: relative;}
      	.login .personal_logo {width: 4rem;height: 4rem;border-radius: 50%;margin: 0 auto 9px;/*position: absolute; top: 60px; left: 20px;*/}
      		.login .userinfo {position: absolute; top: 60px;text-align: center; left: 0; right: 0;}
      		.login .userinfo .title {font-size: 0.8rem; color: #fff;}

      		/* 设置条目 */
      		.item {height: 3rem;line-height: 3rem;padding-left: 0.7rem;background-color: #fff;}
      		.item_ico {float: left;width: 2.3rem;padding: 0.7rem 0.7rem 0.7rem 0;}
      		.item_arrow {float: right;width: 1.5rem;padding: 1rem 0.7rem 1rem 0;}
      		.item span {font-size: 0.7rem;}

      </style>
  </head>
  <body>
<div id="app" v-cloak>

<div class="user_nav_line"></div>
  <div class="aui-refresh-content phone_content" style="height:auto;border-radius:2%;padding:0.5rem 0 1rem;">
    <div class="password_content">
      <i class="aui-iconfont aui-icon-unlock passwore_content_i"></i>
      <input type="password" name="" placeholder="请输入原密码" class="pass_place" v-model="oldpassword">
    </div>
    <div class="password_content">
       <i class="aui-iconfont aui-icon-lock passwore_content_i"></i>
       <input type="password" name="" placeholder="请输入新密码" class="pass_place" v-model="password">
    </div>
    <div class="password_content">
        <i class="aui-iconfont aui-icon-lock passwore_content_i"></i>
        <input type="password" name="" placeholder="请再次输入新密码" class="pass_place" v-model="repassword">
    </div>
    <div class="password_find">忘记密码？</div>
    <button type="button" name="button" class="user_set_btn_one" style="margin-top:1rem;border-radius: 1rem;" @click="submit">确认并修改</button>
</div>
</div>
  </body>
  <script type="text/javascript" src="../../script/api.js"></script>
  <script type="text/javascript" src="../../script/zepto.js"></script>
  <script type="text/javascript" src="../../script/vue.min.js"></script>
  <script type="text/javascript" src="../../script/utils.js"></script>
  <script type="text/javascript" src="../../script/common.js"></script>
  <script type="text/javascript" src="../../script/aui-tab.js"></script>
  <script type="text/javascript" src="../../script/aui-scroll.js"></script>
  <script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
  <script type="text/javascript">
      function openWinInfo(type){
        api.openWin({
            name: 'type',
            url: './userInfo.html',
            pageParam: {
                name: 'test'
            }
        });

      }


      apiready = function(){
        setRefresh()
        var app = new Vue({
          el:"#app",
          data: {
            oldpassword: '',
            password: '',
            repassword: '',
            token: ''
          },
          created:function() {
            var $_this=this;
            $_this.token = $api.getStorage('token') || '';

          },
          methods: {
            submit:function() {
              var $_this=this;
              if( $_this.oldpassword=='' ) {
                api.toast({
                    msg: '原密码不能为空',
                    duration: 1000,
                    location: 'bottom'
                });
                return;
              }else if( $_this.password=='' ) {
                api.toast({
                    msg: '新密码不能为空',
                    duration: 1000,
                    location: 'bottom'
                });
                return;
              }else if( $_this.repassword!=$_this.password ) {
                api.toast({
                    msg: '密码不一致',
                    duration: 1000,
                    location: 'bottom'
                });
                return;
              }
              api.ajax({
                  url: window.Url.Freeucenter_oldChangePass,
                  method: 'post',
                  data: {
                      values: {
                          token: $_this.token,
                          type:6,
                          oldpassword: Base64.encode('UNO'+$_this.oldpassword+'HACHA'),
                          password: Base64.encode('UNO'+$_this.password+'HACHA'),
                          repassword: Base64.encode('UNO'+$_this.repassword+'HACHA')
                      }
                  }
              }, function(ret, err) {
                console.log(JSON.stringify(ret))
                  if (ret.re == 1) {
                    api.toast({
                        msg: '修改成功,请重新登录',
                        duration: 1000,
                        location: 'bottom'
                    });
                    $api.rmStorage('rong-token');
                    $api.rmStorage('user_id');
                    $api.rmStorage('token');
                    $api.rmStorage('user_name');
                    $api.rmStorage('user_phone');
                    $api.rmStorage('user_data');
                    api.execScript({
                        name: 'root',
                        frameName: 'five_frame/index.html',
                        script: 'window.location.reload();'
                    });
                    setTimeout(function() {
                      api.closeWin({
                        name:'person'
                      });
                      api.closeWin({});
                    },1000)

                  } else {
                      api.toast({
                          msg: ret.info,
                          duration: 1000,
                          location: 'bottom'
                      });
                  }
              });
            }
          }
        })

      };


      //刷新
      function setRefresh() {
          var pullRefresh = new auiPullToRefresh({
              container: document.querySelector('.aui-refresh-content'),
              triggerDistance: 100
          }, function(ret) {

              if (ret.status == "success") {
                  setTimeout(function() {
                      pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                  }, 1500)
              }
          })
      }

  </script>
  </html>
